package 动态链表.逢7过;

import 动态数组.线性表.ArrayList;
import 动态链表.LinkedSinglyCircularList;

public class SevenGame {
    public static void main(String[] args) {
        //几个人
        int M = 5;
        //N个数默认从1开始
        int N = 50;
        LinkedSinglyCircularList<ArrayList<String>> list = new LinkedSinglyCircularList<>();
        for (int i = 0; i < M; i++) {
            //为链表添加玩家存储的集合
            list.add(new ArrayList<String>());
        }
        //玩家的id
        int index = 0;
        for (int i = 1; i <= N; i++) {
            list.get(index++ % list.size()).add(getAnsWer(i));
        }

        for (int i = 0; i < M; i++) {
            System.out.println(String.format("玩家%d号的回答顺序为：%s",i + 1,list.get(i)));
        }
    }

    private static String getAnsWer(int i) {
        if (i % 7 == 0){
            return "过";
        }
        if (containSeven(i)){
            return "过";
        }
        return i+"";
    }

    private static boolean containSeven(int i) {
        String num = i + "";
        return num.contains("7");
    }
}
